package model;

import java.io.FileNotFoundException;
import java.io.IOException;


/**
 *
 * @author Romain
 */
public class ModelChat extends AbstractChatModel{

    public ModelChat() throws FileNotFoundException, IOException, ClassNotFoundException {
    }
    
    
    @Override
    public void AddConnToWaitList(Connection paramConn){
        this.waitingList.add(paramConn);
        this.notifyObserverWaitList(waitingList);
    }
    
    @Override
    public void AddConnToActList(Connection paramConn){
        this.activeList.add(paramConn);
        this.notifyObserverActList(activeList);
    }
    
    @Override
    public void RemoveConnWaitList(Connection paramConn){
        //this.waitingList.remove(paramConn);
        
        for ( int i=0; i<waitingList.size(); i++)
        {
            if (waitingList.get(i).getID() == paramConn.getID()) {
                waitingList.remove(i);
            }
        }
        //UpdateList();
        this.notifyObserverWaitList(waitingList);
    }
    
    @Override
    public void RemoveConnActList(Connection paramConn){
        this.activeList.remove(paramConn); 
        this.notifyObserverActList(activeList);
    }
    
    @Override
    public void UpdateList(){
        this.notifyObserverActList(activeList);
        this.notifyObserverActList(waitingList);
        this.notifyObserverUserList(UserList);
        System.out.println("list connection modify");
    }
}
